local function client_login_message()
	local msg;
	local protocol = bin.from_int(1);
	local sn = bin.from_int(0);
	local time = bin.from_int(0);
	local login_type = bin.from_int(0);
	local id1 = bin.from_int(0);
	local id2 = bin.from_int(1);
	local auth = "12345678901234567890123456789012"
	msg = protocol .. sn .. time .. login_type .. id1 .. id2 .. auth;
	return msg;
end

function on_connected(bev)
	print("lua:on_connected");
	local data = client_login_message();
	network.write(bev, bin.from_int(string.len(data) + 4));
	network.write(bev, data);
end

function process_respond(bev, data)
	print("lua:process_respond");
	local len = bin.to_int(string.sub(data,1,4));
	local str = string.sub(data, 5);
	print(len, str);
	loop.exit();
end

function on_closed(bev)
	print("lua:on_closed,exit");
	loop.exit();
end

function on_signal(signal)
	print("lua:on_signal,exit");
	loop.exit();
end
